﻿using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Text;
using System.Linq;

namespace Templates.SharpParts.Shells
{
	public partial class UsingNamespaceShell 
	{
		public override void BeforeToString()
		{
			StringBuilder result = new StringBuilder();

			ReadOnlyCollection<string> namespaceCollection = Namespaces;

			if (namespaceCollection.Count > 0)
			{
				foreach (var ns in namespaceCollection.Where(ns => !string.IsNullOrWhiteSpace(ns)).Select(x => x.Trim()))
				{
					Helpers.UsingNamespace usingNamespaceTemplate = new Helpers.UsingNamespace() { NamespaceName = ns };
					result.AppendLine(usingNamespaceTemplate.ToString());
				}
			}
			NamespacesString = result.ToString();
		}

		private string NamespacesString { get; set; }
	}

}
